﻿/// File: Robotics4.NET\BodyMap\Containers.cs
/// 
/// ------------------------------------------------------------
/// Copyright (c) 2004
///   Antonio Cisternino (cisterni.unipi.it),
///   Diego Colombo      (colombod.unipi.it)
/// 
/// The use and distribution terms for this software are 
/// contained in the file named license.txt, which can be found 
/// in the root of this distribution.
/// By using this software in any fashion, you are agreeing to 
/// be bound by the terms of this license.
///
/// You must not remove this notice, or any other, from this
/// software.
/// ------------------------------------------------------------
#region Using directives

using System;
using System.Collections;
using System.Text;
using System.Xml;

#endregion

namespace Robotics4.NET
{
	public class R4NSectionHandler : System.Configuration.NameValueSectionHandler
	{
	}
#if CF

    public class R4NInterfaceList : IEnumerable
    {
        private ArrayList list = new ArrayList();
        public InterfaceEntry this[int idx]
        {
            get
            {
                return (InterfaceEntry)list[idx];
            }
            set
            {
                list[idx] = value;
            }
        }
        public int Add(InterfaceEntry r)
        {
            return list.Add(r);
        }

        public int Count
        {
            get { return list.Count; }
        }
        public IEnumerator GetEnumerator()
        {
            return list.GetEnumerator();
        }
        public void Clear()
        {
            list.Clear();
        }
    }

    public class R4NInterfaceListContainer : IEnumerable
    {
        internal Hashtable table = new Hashtable();

        public bool ContainsKey(string key)
        {
            return table.ContainsKey(key);
        }

        public R4NInterfaceList this[string key]
        {
            get
            {
                return (R4NInterfaceList)table[key];
            }
            set
            {
                table[key] = value;
            }
        }
        public IEnumerator GetEnumerator()
        {
            return table.GetEnumerator();
        }
    }

    public class R4NRobletsList : IEnumerable
    {
        private ArrayList list = new ArrayList();
        public RobletBase this[int idx]
        {
            get
            {
                return (RobletBase)list[idx];
            }
            set
            {
                list[idx] = value;
            }
        }
        public int Add(RobletBase r)
        {
            return list.Add(r);
        }

        public int Count
        {
            get { return list.Count; }
        }
        public IEnumerator GetEnumerator()
        {
            return list.GetEnumerator();
        }
        public void Clear()
        {
            list.Clear();
        }
    }

    public class R4NXMLDocumentContainer : IEnumerable
    {
        internal Hashtable table;

        public R4NXMLDocumentContainer()
        {
            table = new Hashtable();
        }

        public bool ContainsKey(string key)
        {
            return table.ContainsKey(key);
        }

        public XmlDocument this[string key]
        {
            get
            {
                return (XmlDocument)table[key];
            }
            set
            {
                table[key] = value;
            }
        }



        #region IEnumerable Members

        public IEnumerator GetEnumerator()
        {
            return table.GetEnumerator();
        }

        #endregion
    }

    public class R4NStringListContainer : IEnumerable
    {
        internal Hashtable table;

        public R4NStringListContainer()
        {
            table = new Hashtable();
        }

        public bool ContainsKey(string key)
        {
            return table.ContainsKey(key);
        }

        public R4NStringList this[string key]
        {
            get
            {
                return (R4NStringList)table[key];
            }
            set
            {
                table[key] = value;
            }
        }

        #region IEnumerable Members

        public IEnumerator GetEnumerator()
        {
            return table.GetEnumerator();
        }

        #endregion
    }

    public class R4NStringList : IEnumerable
    {
        internal ArrayList list;

        public R4NStringList()
        {
            list = new ArrayList();
        }

        public string this[int index]
        {
            get
            {
                return (string)list[index];
            }
            set
            {
                list[index] = value;
            }
        }

        public int Add(string str)
        {
            return list.Add(str);
        }

        public bool Contains(string item)
        {
            return list.Contains(item);
        }

        #region IEnumerable Members

        public IEnumerator GetEnumerator()
        {
            return list.GetEnumerator(); ;
        }

        #endregion
    }

    public class R4NRobletMessagesList : IEnumerable
    {
        internal ArrayList list;

        public R4NRobletMessagesList()
        {
            list = new ArrayList();
        }

        public RobletMessage this[int index]
        {
            get
            {
                return (RobletMessage)list[index];
            }
            set
            {
                list[index] = value;
            }
        }

        public int Add(RobletMessage msg)
        {
            return list.Add(msg);
        }

        public bool Contains(RobletMessage item)
        {
            return list.Contains(item);
        }

        #region IEnumerable Members

        public IEnumerator GetEnumerator()
        {
            return list.GetEnumerator(); ;
        }

        #endregion
    }

    public class R4NFriendsList : IEnumerable
    {
        internal Hashtable table;

        public R4NFriendsList()
        {
            table = new Hashtable();
        }

        public bool ContainsKey(string key)
        {
            return table.ContainsKey(key);
        }

        public FriendInfo this[string key]
        {
            get
            {
                return (FriendInfo)table[key];
            }
            set
            {
                table[key] = value;
            }
        }

        #region IEnumerable Members

        public IEnumerator GetEnumerator()
        {
            return table.GetEnumerator();
        }

        #endregion
    }

    internal class R4NTimerEntryList : IEnumerable
    {
        private ArrayList items;
        internal R4NTimerEntryList()
        {
            items = new ArrayList();
        }

        internal void Add(RobletBase.TimerEntry e)
        {
            items.Add(e);
        }

        internal void RemoveAt(int idx)
        {
            items.RemoveAt(idx);
        }

        internal RobletBase.TimerEntry this[int idx]
        {
            get
            {
                return items[idx] as RobletBase.TimerEntry;
            }
            set
            {
                items[idx] = value;
            }
        }

        internal int Count
        {
            get
            {
                return items.Count;
            }
        }

            #region IEnumerable Members

        public IEnumerator GetEnumerator()
        {
            return items.GetEnumerator();
        }

            #endregion
    }
#endif
}
